Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
@web/dev-server-core
Advanced tools
@web/dev-server-core is a core library for creating a modern web development server. It provides a flexible and extensible platform for serving web applications, with support for modern web features like ES modules, hot module replacement (HMR), and middleware.
Basic Server Setup
This code demonstrates how to set up a basic development server using @web/dev-server-core. The server will serve files from the './public' directory on port 8080.
const { startDevServer } = require('@web/dev-server-core');
const config = {
port: 8080,
rootDir: './public',
};
startDevServer({ config }).then(server => {
console.log(`Server running at http://localhost:${config.port}`);
});
Middleware Support
This example shows how to add middleware to the development server. The middleware logs each request URL to the console.
const { startDevServer } = require('@web/dev-server-core');
const config = {
port: 8080,
rootDir: './public',
middleware: [
(ctx, next) => {
console.log(`Request: ${ctx.url}`);
return next();
}
]
};
startDevServer({ config }).then(server => {
console.log(`Server running at http://localhost:${config.port}`);
});
Hot Module Replacement (HMR)
This code demonstrates how to enable Hot Module Replacement (HMR) in the development server. HMR allows modules to be updated in the browser without a full page reload.
const { startDevServer } = require('@web/dev-server-core');
const config = {
port: 8080,
rootDir: './public',
watch: true,
hmr: true
};
startDevServer({ config }).then(server => {
console.log(`Server running with HMR at http://localhost:${config.port}`);
});
webpack-dev-server is a development server that provides live reloading and HMR for webpack projects. It is tightly integrated with webpack and offers a range of features for development, including middleware support and proxying. Compared to @web/dev-server-core, webpack-dev-server is more focused on webpack-specific workflows.
Vite is a modern development server and build tool that offers fast development and optimized production builds. It supports ES modules, HMR, and a plugin system. Vite is designed to be framework-agnostic and provides a faster development experience compared to traditional bundlers. It offers similar functionalities to @web/dev-server-core but with a focus on speed and simplicity.
Parcel is a web application bundler that offers zero configuration and fast performance. It includes a development server with HMR and supports a wide range of file types out of the box. Parcel aims to provide an easy-to-use development experience with minimal setup, making it a good alternative to @web/dev-server-core for developers looking for simplicity.
Core library powering the web server of @web/test-runner and @web/dev-server
See our website for full documentation.
FAQs
Web dev server core
The npm package @web/dev-server-core receives a total of 61,549 weekly downloads. As such, @web/dev-server-core popularity was classified as popular.
We found that @web/dev-server-core demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 7 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.